/**
 * @file test_proj.cpp
 * @author your name (you@domain.com)
 * @brief 
 * @version 0.1
 * @date 2022-09-11
 * 
 * @copyright Copyright (c) 2022
 * 编译测试指令
 * catkin_make -DCATKIN_WHITELIST_PACKAGES=projection run_tests
 * 
 */


// Bring in gtest
#include <gtest/gtest.h>
#include <iostream>

//使用时，包含此头文件
#include <yjkj_projection/proj4.h>
#include <chrono>


// test whether the content of a conversion
// to a ROS message correctly maintains the data.
TEST(ConversionTest, proj4)
{
  double lon = 114.1234567;
  double lat = 30.1234567;
  double x = 511897.11049204;
  double y = 3333805.435786817;

  std::string sour_EPSG = "EPSG:4326"; //wgs84
  std::string des_EPSG = "EPSG:4547"; //cgcs2000：：中央经线114
  common::Proj4 LL_gaus(sour_EPSG, des_EPSG);
  //proj4

  std::array<double, 2> local = {0, 0};
  LL_gaus.FWD(lon, lat, &local[0], &local[1]);
  std::cout << std::fixed << std::setprecision(3);
  std::cout << "east: " << local[0] << std::endl;
  std::cout << "north: " << local[1] << std::endl;

  std::array<double, 2> lonlat = {0, 0};
  LL_gaus.INV(local[0], local[1], &lonlat[0], &lonlat[1]);
  std::cout << std::fixed << std::setprecision(7);
  std::cout << "lon: " << lonlat[0] << std::endl;
  std::cout << "lat: " << lonlat[1] << std::endl;
}

// Run all the tests that were declared with TEST()
int main(int argc, char **argv)
{
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
